import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // 重定向
    { path: '/', redirect: '/login' },
    // 登录页
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
    },
    // 主页
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home/index.vue'),
      // 二级路由
      children: [
        {
          path: 'user', component: () => import('@/views/home/user.vue'),
          children: [
            { path: 'userInfo', component: () => import('@/views/home/userInfo.vue') }
          ]
        }
      ]
    }
  ],
})

export default router
